import { useMemo } from 'react';
import { PickerDataNames } from '../interface';

const usePickerDataNames = (
	dataNames?: PickerDataNames,
): Required<PickerDataNames> => {
	const label = (dataNames && dataNames.label) || 'label';
	const value = (dataNames && dataNames.value) || 'value';
	const children = (dataNames && dataNames.children) || 'children';

	return useMemo<Required<PickerDataNames>>(() => {
		return { label, value, children };
	}, [children, label, value]);
};

export default usePickerDataNames;
